package com.ycy.smartcourseselection.controller;

import com.ycy.smartcourseselection.common.PageResVO;
import com.ycy.smartcourseselection.common.ResData;
import com.ycy.smartcourseselection.dto.courseManage.CoManagesDTO;
import com.ycy.smartcourseselection.dto.score.FileScoreDTO;
import com.ycy.smartcourseselection.dto.score.FindPageScoreDTO;
import com.ycy.smartcourseselection.dto.score.ScoreDTO;
import com.ycy.smartcourseselection.dto.score.ScoreStuChartDTO;
import com.ycy.smartcourseselection.dto.student.FindAllStuDTO;
import com.ycy.smartcourseselection.entity.CoManage;
import com.ycy.smartcourseselection.service.CoManageService;
import com.ycy.smartcourseselection.service.ScoreService;
import com.ycy.smartcourseselection.vo.score.ScoreAnalyseVO;
import com.ycy.smartcourseselection.vo.score.ScoreStuChartVO;
import com.ycy.smartcourseselection.vo.score.ScoreVO;
import com.ycy.smartcourseselection.vo.teacher.HomePageVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "分数管理")
@RestController
@RequestMapping("/score")
public class ScoreController {
    @Resource
    private ScoreService scoreService;

    //修改
    @PostMapping("/save")
    @ApiOperation(value="分数 -- 增加或修改",notes = "带id是修改")
    public ResData<Boolean> saveScore(@RequestBody ScoreDTO scoreDTO) {
        return scoreService.saveScore(scoreDTO);
    }

    //批量修改
    @PostMapping("/findPage")
    @ApiOperation(value="分数 -- 分页查",notes = "other是可选参数")
    public ResData<PageResVO<ScoreVO>> findPageScore(@RequestBody FindPageScoreDTO findPageScoreDTO) {
        return scoreService.findPageScore(findPageScoreDTO);
    }

    //查询课程分析图表数据
    @GetMapping("/analyseScoreByTch")
    @ApiOperation(value="分数 -- 查询教师按课程分析的数据")
    public ResData<ScoreAnalyseVO> findScoreAnalyseData(String courseId) {
        return scoreService.findScoreAnalyseData(courseId);
    }

    //查询按学生分析的数据
    @PostMapping("/analyseScoreByStu")
    @ApiOperation(value="分数 -- 查询按学生分析的数据",notes = "other是可选参数")
    public ResData<ScoreStuChartVO> findScoreStuChartData(@RequestBody ScoreStuChartDTO scoreStuChartDTO) {
        return scoreService.findScoreStuChartData(scoreStuChartDTO);
    }

    @GetMapping("/fileExport")
    @ApiOperation("分数 -- 表格学生成绩导出")
    public void stuInfoExport(HttpServletResponse response,  FileScoreDTO fileScoreDTO) {
        scoreService.scoreExport(response, fileScoreDTO);
    }
}
